home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-19 | 2.6 KB | 43 lines | [TEXT/MMCC] |
- //------------------------------------------------------------------------------
- // File: bound.cp
- // Date: 7/20/94
- // Author: Bretton Wade
- //
- // Description: this file contains the class definition for a bound widget. a
- // bound widget is a user interface item that frames other
- // types of widgets.
- //
- //------------------------------------------------------------------------------
-
- #include "bound.h"
-
- //------------------------------------------------------------------------------
- // constructor
- //------------------------------------------------------------------------------
- bound::bound (Rect &c1, Rect &c2) : widget () // constructor
- { // begin
- constrain = c1; // copy the constrain values
- constraint = c2; // copy the parent relationship
- } // end
-
- //------------------------------------------------------------------------------
- // resize the widget
- //------------------------------------------------------------------------------
- void bound::Resize (EventRecord &event) // recompute sizing information from parent
- { // begin
- Rect bnd = (*region)->rgnBBox; // copy my current bounding rect
- short *pbnd = (short *) &(*(parent->region))->rgnBBox; // get a pointer to the parent bound
- if (constrain.top >= 0) // if the top of the bound is constrained
- bnd.top = pbnd[constrain.top] + constraint.top; // update my bounds according to my constraints and parent rect
- if (constrain.left >= 0) // if the left of the bound is constrained
- bnd.left = pbnd[constrain.left] + constraint.left; // update my bounds according to my constraints and parent rect
- if (constrain.bottom >= 0) // if the bottom of the bound is constrained
- bnd.bottom = pbnd[constrain.bottom] + constraint.bottom; // update my bounds according to my constraints and parent rect
- if (constrain.right >= 0) // if the right of the bound is constrained
- bnd.right = pbnd[constrain.right] + constraint.right; // update my bounds according to my constraints and parent rect
- RectRgn (region, &bnd); // recompute my region
- widget::Resize (event); // do what the other widgets do
- } // end
-
- //------------------------------------------------------------------------------
-